using System;
using System.Collections.Generic;
using Meditek.Entities;
namespace Meditek.UI
{
	public class ReferenceConverter 
	{
	
		public static List<AdministrationVias> AdministrationViasList = null;
		public static List<Users> UsersList = null;
		public static List<Allergies> AllergiesList = null;
		public static List<Persons> PersonsList = null;
		public static List<Severitys> SeveritysList = null;
		public static List<_Status> _StatusList = null;
		public static List<Conditions> ConditionsList = null;
		public static List<Inmunizations> InmunizationsList = null;
		public static List<_Procedures> _ProceduresList = null;
		public static List<BloodTypes> BloodTypesList = null;
		public static List<ContactData> ContactDataList = null;
		public static List<Patients> PatientsList = null;
		public static List<Races> RacesList = null;
		public static List<Sexs> SexsList = null;
		public static List<TestResults> TestResultsList = null;
		public static List<Medications> MedicationsList = null;

        #region IValueConverter Members
        
        public object Convert(object value, object parameter)
        {
			if (value == null)
				return null;
            else
            {
				if(parameter.ToString() == "AdministrationVias")
				{
					foreach (AdministrationVias administrationVias in AdministrationViasList)
					{	
						if (administrationVias.idAdministrationVia.ToString() == value.ToString())
							return administrationVias.Name;
					}
				}
				if(parameter.ToString() == "Users")
				{
					foreach (Users users in UsersList)
					{	
						if (users.idUser.ToString() == value.ToString())
							return users.Login;
					}
				}
				if(parameter.ToString() == "Allergies")
				{
					foreach (Allergies allergies in AllergiesList)
					{	
						if (allergies.idAllergie.ToString() == value.ToString())
							return allergies.Name;
					}
				}
				if(parameter.ToString() == "Persons")
				{
					foreach (Persons persons in PersonsList)
					{	
						if (persons.idPerson.ToString() == value.ToString())
							return persons.idPerson;
					}
				}
				if(parameter.ToString() == "Severitys")
				{
					foreach (Severitys severitys in SeveritysList)
					{	
						if (severitys.idSeverity.ToString() == value.ToString())
							return severitys.Name;
					}
				}
				if(parameter.ToString() == "_Status")
				{
					foreach (_Status _Status in _StatusList)
					{	
						if (_Status.idStatus.ToString() == value.ToString())
							return _Status.Name;
					}
				}
				if(parameter.ToString() == "Conditions")
				{
					foreach (Conditions conditions in ConditionsList)
					{	
						if (conditions.idConditions.ToString() == value.ToString())
							return conditions.Name;
					}
				}
				if(parameter.ToString() == "Inmunizations")
				{
					foreach (Inmunizations inmunizations in InmunizationsList)
					{	
						if (inmunizations.idInmunization.ToString() == value.ToString())
							return inmunizations.Name;
					}
				}
				if(parameter.ToString() == "_Procedures")
				{
					foreach (_Procedures _Procedures in _ProceduresList)
					{	
						if (_Procedures.idProcedure.ToString() == value.ToString())
							return _Procedures.Name;
					}
				}
				if(parameter.ToString() == "BloodTypes")
				{
					foreach (BloodTypes bloodTypes in BloodTypesList)
					{	
						if (bloodTypes.idBloodType.ToString() == value.ToString())
							return bloodTypes.Name;
					}
				}
				if(parameter.ToString() == "ContactData")
				{
					foreach (ContactData contactData in ContactDataList)
					{	
						if (contactData.idContactData.ToString() == value.ToString())
							return contactData.FirstName;
					}
				}
				if(parameter.ToString() == "Patients")
				{
					foreach (Patients patients in PatientsList)
					{	
						if (patients.idPatient.ToString() == value.ToString())
							return patients.idPatient;
					}
				}
				if(parameter.ToString() == "Races")
				{
					foreach (Races races in RacesList)
					{	
						if (races.idRace.ToString() == value.ToString())
							return races.Name;
					}
				}
				if(parameter.ToString() == "Sexs")
				{
					foreach (Sexs sexs in SexsList)
					{	
						if (sexs.idSex.ToString() == value.ToString())
							return sexs.Name;
					}
				}
				if(parameter.ToString() == "TestResults")
				{
					foreach (TestResults testResults in TestResultsList)
					{	
						if (testResults.idTestResult.ToString() == value.ToString())
							return testResults.Name;
					}
				}
				if(parameter.ToString() == "Medications")
				{
					foreach (Medications medications in MedicationsList)
					{	
						if (medications.idMedication.ToString() == value.ToString())
							return medications.Name;
					}
				}
			}
			return value;
        }
        
        public object ConvertBack(object value, object parameter)
        {
            return value;
        }

        #endregion
        
    }
}
